import React from 'react';
import { connect } from 'react-redux';
import {hashHistory } from 'react-router'
import {news_cms_art_list} from '../../actions';

var Recommond = React.createClass({
  componentDidMount:function(){
    const {dispatch} = this.props;
    dispatch(news_cms_art_list())
  },
  render:function(){
    console.log(this.props.news_cms_art_list);
    let news_cms_art_list = this.props.news_cms_art_list,
        id = this.props.id;
    // console.log(this.props.id);
    return(
      <div className="art_detail">
        {
          news_cms_art_list.map(function(item,index){
            if(item.id==id){
              $('.contant').html(item.content)
              return(
                  <div className="top">
                    <h4>{item.className} | {item.title}</h4>
                    <div className="origin">
                      {/* <em></em> */}
                      {item.createUserName}
                    </div>
                  </div>
              )
            }
          })
        }
        <div className="contant">
          {/* {item.content} */}
        </div>
      </div>
    )
  }
})

let mapStateToProps = (state,own)=>{
  let news_cms_art_list = state.news.news_cms_art_list ||[];
  return{
    news_cms_art_list,
    id:own.params.id
  }
}

export default connect(mapStateToProps)(Recommond);
